/*-------------------------------------
		sPlugin
	    By Scooby, 2010
-------------------------------------*/

local PLUGIN = {}

PLUGIN.Name = "God"
PLUGIN.Author = "Scooby"
PLUGIN.Command = "god"
PLUGIN.Group = 2
PLUGIN.Category = "Fun"
PLUGIN.Format = "string"
PLUGIN.Use = "<Player> <1/0>"
PLUGIN.Menu = {
	{
		title = "Choose Player",
		cont = "#players",
		apos = 1
	}
}


function PLUGIN:Main( ply, args )
	
	local pl = spl:FindPly( args[1] )
	local on = tonumber( args[2] ) or 1
	
	if( #pl == 0 ) then
		spl:PrintC( ply, spl.red, spl.fnp )
		return false
	elseif( #pl > 1 ) then
		spl:PrintC( ply, spl.red, spl.fmp )
		return false
	end
	
	if( on == 1 ) then
		if( pl[1]:GetNWBool( "Admin_GOD" ) == false ) then
			hook.Add( "PlayerShouldTakeDamage", "ADMIN_GOD_"..pl[1]:SteamID(), function( plys )
				if( plys == pl[1] ) then return false end
			end)
			pl[1]:SetNWBool( "Admin_GOD", true )
			spl:PrintC( spl.blue, ply:Nick(), spl.white, " Enabled Godmode On ",spl.green, pl[1]:Nick()  )
		else
			spl:PrintC( ply, spl.red, "That Player Is Already In God Mode" )
			return false
		end
	elseif( on == 0 ) then
		if( pl[1]:GetNWBool( "Admin_GOD" ) == true ) then
			hook.Remove( "PlayerShouldTakeDamage", "ADMIN_GOD_"..pl[1]:SteamID() )
			spl:PrintC( spl.blue, ply:Nick(), spl.white, " Disabled Godmode On ",spl.green, pl[1]:Nick()  )
			pl[1]:SetNWBool( "Admin_GOD", false )
		else
			spl:PrintC( ply, spl.red, "That Player Is Not Godded" )
			return false
		end
	end
	
end

spl:AddPlugin( PLUGIN )